<script setup lang="ts">
  import { ref } from 'vue';
  // 定义组件的 props
  const props = defineProps({
    msg: {
      type: String,
      required: true
    }
  });

  // 定义组件的 emits
  const emit = defineEmits(['handleParentClick']);

  const msg = ref<string>('');
  const nums = ref<number[]>([1, 2, 3, 4, 5]);
  console.log(props.msg);
  const handleClick = () => {
    nums.value.push(6); 
  }

  const handleParentClick=()=>{
    emit('handleParentClick');
  }

  defineExpose({
    handleClick
  })
</script>

<template>
  <div class="testpage">
    test--{{msg}}
    <div v-for="(item,index) in nums" :key="index">{{item}}</div>
    <van-button type="warning" @click="handleParentClick">操作父组件</van-button>
  </div>
</template>

<style lang="scss" scoped>
  .testpage{
    background-color: green;
    padding:20px 0;
    margin-bottom:60px;
  }
</style>
